<?php

namespace Database\Seeders;

use Dcat\Admin\Models\AdminTablesSeeder;
use Dcat\Admin\Models\Menu;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Artisan;

class AdminSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $userModel = config('admin.database.users_model');

        if ($userModel::count() == 0) {
            Artisan::call('db:seed', ['--class' => AdminTablesSeeder::class]);
        }
        $createdAt = date('Y-m-d H:i:s');

        $order = 1;

        Menu::query()->truncate();
        Menu::query()->insert([
            [
                'id'            => 1,
                'parent_id'     => 0,
                'title'         => '首页',
                'icon'          => 'feather icon-bar-chart-2',
                'order'         => $order++,
                'uri'           => '/',
                'created_at'    => $createdAt,
            ],




            //endregion




            //region APP管理
            [
                'id'            => 2,
                'parent_id'     => 0,
                'title'         => '系统配置',
                'icon'          => 'fa-cubes',
                'order'         => $order++,
                'uri'           => '',
                'created_at'    => $createdAt,
            ],
            [
                'id'            => 21,
                'parent_id'     => 2,
                'title'         => '版本管理',
                'icon'          => 'fa-cube',
                'order'         => $order++,
                'uri'           => '/version',
                'created_at'    => $createdAt,
            ],
            [
                'id'            => 22,
                'parent_id'     => 2,
                'title'         => 'app设置',
                'icon'          => 'fa-cube',
                'order'         => $order++,
                'uri'           => '/setting/add',
                'created_at'    => $createdAt,
            ],
            [
                'id'            => 23,
                'parent_id'     => 2,
                'title'         => '协议管理',
                'icon'          => 'fa-cube',
                'order'         => $order++,
                'uri'           => '/app_info',
                'created_at'    => $createdAt,
            ],


            //endregion

            //region Admin
            [
                'id'            => 3,
                'parent_id'     => 0,
                'title'         => '权限管理',
                'icon'          => 'feather icon-settings',
                'order'         => $order++,
                'uri'           => '',
                'created_at'    => $createdAt,
            ],
            [
                'id'            => 31,
                'parent_id'     => 3,
                'title'         => 'Users',
                'icon'          => '',
                'order'         => $order++,
                'uri'           => 'auth/users',
                'created_at'    => $createdAt,
            ],
            [
                'id'            => 32,
                'parent_id'     => 3,
                'title'         => 'Roles',
                'icon'          => '',
                'order'         => $order++,
                'uri'           => 'auth/roles',
                'created_at'    => $createdAt,
            ],
            [
                'id'            => 33,
                'parent_id'     => 3,
                'title'         => 'Permission',
                'icon'          => '',
                'order'         => $order++,
                'uri'           => 'auth/permissions',
                'created_at'    => $createdAt,
            ],
            [
                'id'            => 34,
                'parent_id'     => 3,
                'title'         => 'Menu',
                'icon'          => '',
                'order'         => $order++,
                'uri'           => 'auth/menu',
                'created_at'    => $createdAt,
            ],
            [
                'id'            => 35,
                'parent_id'     => 3,
                'title'         => 'Extensions',
                'icon'          => '',
                'order'         => $order++,
                'uri'           => 'auth/extensions',
                'created_at'    => $createdAt,
            ],

            //
            [
                'id'            => 4,
                'parent_id'     => 0,
                'title'         => '用户管理',
                'icon'          => 'fa-cubes',
                'order'         => $order++,
                'uri'           => '',
                'created_at'    => $createdAt,
            ],
            [
                'id'            => 41,
                'parent_id'     => 4,
                'title'         => '用户列表',
                'icon'          => 'fa-cubes',
                'order'         => $order++,
                'uri'           => '/user',
                'created_at'    => $createdAt,
            ],
            [
                'id'            => 5,
                'parent_id'     => 0,
                'title'         => '会员配置',
                'icon'          => 'fa-cubes',
                'order'         => $order++,
                'uri'           => '',
                'created_at'    => $createdAt,
            ],
            [
                'id'            => 51,
                'parent_id'     => 5,
                'title'         => '会员配置',
                'icon'          => 'fa-cubes',
                'order'         => $order++,
                'uri'           => '/member',
                'created_at'    => $createdAt,
            ],
            [
                'id'            => 52,
                'parent_id'     => 5,
                'title'         => '权益配置',
                'icon'          => 'fa-cubes',
                'order'         => $order++,
                'uri'           => '/member_benefits',
                'created_at'    => $createdAt,
            ],

            [
                'id'            => 6,
                'parent_id'     => 0,
                'title'         => '任务管理',
                'icon'          => 'fa-cubes',
                'order'         => $order++,
                'uri'           => '',
                'created_at'    => $createdAt,
            ],
            [
                'id'            => 61,
                'parent_id'     => 6,
                'title'         => '任务配置',
                'icon'          => 'fa-cubes',
                'order'         => $order++,
                'uri'           => '/task',
                'created_at'    => $createdAt,
            ],

            [
                'id'            => 7,
                'parent_id'     => 0,
                'title'         => '反馈管理',
                'icon'          => 'fa-cubes',
                'order'         => $order++,
                'uri'           => '',
                'created_at'    => $createdAt,
            ],
            [
                'id'            => 71,
                'parent_id'     => 7,
                'title'         => '意见反馈',
                'icon'          => 'fa-cubes',
                'order'         => $order++,
                'uri'           => '/feedback',
                'created_at'    => $createdAt,
            ],
            [
                'id'            => 8,
                'parent_id'     => 0,
                'title'         => '案例管理',
                'icon'          => 'fa-cubes',
                'order'         => $order++,
                'uri'           => '',
                'created_at'    => $createdAt,
            ],
            [
                'id'            => 81,
                'parent_id'     => 8,
                'title'         => '案例列表',
                'icon'          => 'fa-cubes',
                'order'         => $order++,
                'uri'           => '/case',
                'created_at'    => $createdAt,
            ],

            //endregion
        ]);

        (new Menu())->flushCache();
    }
}
